//
//  JoinQuizCell.m
//  WanCaiC8
//
//  Created by tangang on 2018/1/28.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "JoinQuizCell.h"

@implementation JoinQuizCell{
    UIImageView *icon;
    QXLable     *labName;
    UIButton    *btnCount;
    UIButton    *btnPosting;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        WS(weakSelf);
        icon=[[UIImageView alloc]init];
        [self.contentView addSubview:icon];
        [icon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).with.offset(13);
            make.centerY.equalTo(weakSelf.contentView);
            make.size.mas_equalTo(CGSizeMake(50, 50));
        }];
        labName=[[QXLable alloc]initTitle];
        [self.contentView addSubview:labName];
        [labName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(icon.mas_right).with.offset(13);
            make.top.equalTo(icon);
            make.size.mas_equalTo(CGSizeMake(150, 30));
        }];
        btnCount=[[UIButton alloc]init];
        btnCount.contentHorizontalAlignment=
        UIControlContentHorizontalAlignmentLeft;
        [btnCount setImage:[UIImage imageNamed:@"master_integral"] forState:UIControlStateNormal];
        [btnCount setTitleColor:[UIColor colorWithHexString:@"#F09330"] forState:UIControlStateNormal];
        btnCount.userInteractionEnabled=NO;
        [btnCount setTitle:@" 1024" forState:UIControlStateNormal];
        [btnCount.titleLabel setFont:[UIFont systemFontOfSize:12]];
        [self.contentView addSubview:btnCount];
        [btnCount mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(icon.mas_right).with.offset(13);
            make.top.equalTo(labName.mas_bottom);
            make.size.mas_equalTo(CGSizeMake(150, 20));
        }];
        
        UIImageView *arrImage=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"arrow_right"]];
        [self.contentView addSubview:arrImage];
        [arrImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(weakSelf.contentView);
            make.right.equalTo(weakSelf.contentView).with.offset(-13);
            make.size.mas_equalTo(arrImage.image.size);
        }];
        
        UIView *line=[[UIView alloc]init];
        line.backgroundColor=DEFAULTBGCOLOR;
        [self.contentView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(weakSelf.contentView);
            make.height.mas_equalTo(@.7);
        }];
    }
    return self;
}

- (void)setModel:(QuizLotteryModel *)model{
    _model=model;
    [icon sd_setImageWithURL:[NSURL URLWithString:model.LotteryIcon]];
    labName.text=model.Name;
    [btnCount setTitle:[NSString stringWithFormat:@" %ld",model.Score] forState:UIControlStateNormal];
}

@end
